#pragma once

#include <iostream>
#include <string>
#include <functional>
#include <pthread.h>
#include "log.hpp"

class Task
{
public:
    // typedef std::function<void(int, std::string, uint16_t)> callback_t;
    using callback_t = std::function<void(int, std::string, uint16_t)>;

private:
    int sock_;        // 给用户提供IO服务的sock
    uint16_t port_;   // client port
    std::string ip_;  // client ip
    callback_t func_; // 任务的回调方法
public:
    Task() : sock_(-1), port_(-1) {}
    Task(int sock, std::string ip, uint16_t port, callback_t func)
        : sock_(sock), ip_(ip), port_(port), func_(func) {}
    ~Task() {}

    void operator()()
    {        
        func_(sock_, ip_, port_);
    }
};